<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box {
            width: 100px;
            height: 100px;
            border: 1px solid;
        }
    </style>
</head>

<body>
    <div id="box"></div>
    <script src="../tools.js"></script>
    <script>

        let name = 'zhangsan', age = 18;
        console.log(`我叫${name},我${age}岁`);

        box.onclick = function () {
            let r = random(255), g = random(255), b = random(255);
            // box.style.background = 'red';
            // box.style.background = `rgb(${r},${g},${b})`;
            box.style.background = `rgb(${random(255)},${random(255)},${random(255)})`;
        }

        // let arr = ['red', 'yellow', 'green'];
        // box.onclick = function () {
        //     let index = random(arr.length - 1);
        //     box.style.background = arr[index];
        // }

    </script>

</body>

</html>